package com.siemens.industrial.model.partner;

import org.springframework.jdbc.core.RowMapper;

import java.util.Date;

/**
 * Created by weig on 8/23/16.
 */
public class DeviceStatePeriod {
    private String deviceId;
    private int state;
    private Date startTime;
    private Date endTime;
    private Date createTime;
    private int statusType;

    private static final RowMapper<DeviceStatePeriod> rowMapper = (resultSet, i) -> {
        DeviceStatePeriod deviceStatePeriod = new DeviceStatePeriod();
        deviceStatePeriod.setDeviceId(resultSet.getString("device_id"));
        deviceStatePeriod.setState(resultSet.getInt("state"));
        deviceStatePeriod.setStartTime(new Date(resultSet.getTimestamp("start_time").getTime()));
        deviceStatePeriod.setEndTime(resultSet.getTimestamp("end_time") == null ? null : new Date(resultSet.getTimestamp("end_time").getTime()));
        deviceStatePeriod.setCreateTime(new Date(resultSet.getTimestamp("create_time").getTime()));
        return deviceStatePeriod;
    };

    public static RowMapper<DeviceStatePeriod> getRowMapper() {
        return rowMapper;
    }

    //<editor-fold desc="getters and setters">

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public int getStatusType() {
        return statusType;
    }

    public void setStatusType(int statusType) {
        this.statusType = statusType;
    }

    //</editor-fold>
}
